Loop Statements execute its Body multiple times (while condition is TRUE or while iterating through Elements)
● for Statement iterates through Sequence or Array Elements and executes its Body for each Element.
● while Statement executes its Body while condition is TRUE. Condition is checked at the beginning of Body
● do ... while Statement executes its Body while condition is TRUE. Condition is checked at the end of Body.
You can use
● break Jump Statement to exit Loop Statement
● continue Jump Statement to skip rest of the Body and continue with next iteration from the beginning of Body
for
for(int i=1, j=5 ; i<=4 && j>2 ; i++, j--){
System.out.println(i);
}
while
while(i<=4) {
i++;
System.out.println(i);
}
do ... while
do{
i++;
System.out.println(i);
}while(i<=4);